<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=9"/>
<title>wwwApp: user/utils.php File Reference</title>
<link href="tabs.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="dynsections.js"></script>
<link href="search/search.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="search/search.js"></script>
<script type="text/javascript">
  $(document).ready(function() { searchBox.OnSelectItem(0); });
</script>
<link href="doxygen.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div id="top"><!-- do not remove this div, it is closed by doxygen! -->
<div id="titlearea">
<table cellspacing="0" cellpadding="0">
 <tbody>
 <tr style="height: 56px;">
  <td style="padding-left: 0.5em;">
   <div id="projectname">wwwApp
   </div>
   <div id="projectbrief">A web app for workshop organizing, recruitment and qualification</div>
  </td>
 </tr>
 </tbody>
</table>
</div>
<!-- end header part -->
<!-- Generated by Doxygen 1.8.1.1 -->
<script type="text/javascript">
var searchBox = new SearchBox("searchBox", "search",false,'Search');
</script>
  <div id="navrow1" class="tabs">
    <ul class="tablist">
      <li><a href="index.html"><span>Main&#160;Page</span></a></li>
      <li><a href="annotated.html"><span>Classes</span></a></li>
      <li class="current"><a href="files.html"><span>Files</span></a></li>
      <li>
        <div id="MSearchBox" class="MSearchBoxInactive">
        <span class="left">
          <img id="MSearchSelect" src="search/mag_sel.png"
               onmouseover="return searchBox.OnSearchSelectShow()"
               onmouseout="return searchBox.OnSearchSelectHide()"
               alt=""/>
          <input type="text" id="MSearchField" value="Search" accesskey="S"
               onfocus="searchBox.OnSearchFieldFocus(true)" 
               onblur="searchBox.OnSearchFieldFocus(false)" 
               onkeyup="searchBox.OnSearchFieldChange(event)"/>
          </span><span class="right">
            <a id="MSearchClose" href="javascript:searchBox.CloseResultsWindow()"><img id="MSearchCloseImg" border="0" src="search/close.png" alt=""/></a>
          </span>
        </div>
      </li>
    </ul>
  </div>
  <div id="navrow2" class="tabs2">
    <ul class="tablist">
      <li><a href="files.html"><span>File&#160;List</span></a></li>
      <li><a href="globals.html"><span>File&#160;Members</span></a></li>
    </ul>
  </div>
<!-- window showing the filter options -->
<div id="MSearchSelectWindow"
     onmouseover="return searchBox.OnSearchSelectShow()"
     onmouseout="return searchBox.OnSearchSelectHide()"
     onkeydown="return searchBox.OnSearchSelectKey(event)">
<a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(0)"><span class="SelectionMark">&#160;</span>All</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(1)"><span class="SelectionMark">&#160;</span>Classes</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(2)"><span class="SelectionMark">&#160;</span>Files</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(3)"><span class="SelectionMark">&#160;</span>Functions</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(4)"><span class="SelectionMark">&#160;</span>Variables</a></div>

<!-- iframe showing the search results (closed by default) -->
<div id="MSearchResultsWindow">
<iframe src="javascript:void(0)" frameborder="0" 
        name="MSearchResults" id="MSearchResults">
</iframe>
</div>

<div id="nav-path" class="navpath">
  <ul>
<li class="navelem"><a class="el" href="dir_111cd2f11cffd6d6d28d89ee0389ee9e.html">user</a></li>  </ul>
</div>
</div><!-- top -->
<div class="header">
  <div class="summary">
<a href="#func-members">Functions</a>  </div>
  <div class="headertitle">
<div class="title">utils.php File Reference</div>  </div>
</div><!--header-->
<div class="contents">

<p><a href="user_2utils_8php_source.html">Go to the source code of this file.</a></p>
<table class="memberdecls">
<tr class="heading"><td colspan="2"><h2><a name="func-members"></a>
Functions</h2></td></tr>
<tr class="memitem:ae6297fbd3e8fa7cc5feb6411a80deee9"><td class="memItemLeft" align="right" valign="top">&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="user_2utils_8php.html#ae6297fbd3e8fa7cc5feb6411a80deee9">userIs</a> ($role)</td></tr>
<tr class="memitem:a1e9c8ed2c5ed2def1a367c9ffd04114b"><td class="memItemLeft" align="right" valign="top">&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="user_2utils_8php.html#a1e9c8ed2c5ed2def1a367c9ffd04114b">userCan</a> ($action, $owners=false)</td></tr>
<tr class="memitem:a5bbc4a39c360e15b0c00714f18d2082b"><td class="memItemLeft" align="right" valign="top">&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="user_2utils_8php.html#a5bbc4a39c360e15b0c00714f18d2082b">assertProfileFilled</a> ($quiet=false)</td></tr>
<tr class="memitem:a94decde67d97df23a5959d489659b322"><td class="memItemLeft" align="right" valign="top">&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="user_2utils_8php.html#a94decde67d97df23a5959d489659b322">gender</a> ($m='y', $f='a', $gender='user')</td></tr>
<tr class="memitem:a7144fa5a413ad5690425b7b720aeedba"><td class="memItemLeft" align="right" valign="top">&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="user_2utils_8php.html#a7144fa5a413ad5690425b7b720aeedba">genderize</a> ($s, $<a class="el" href="user_2utils_8php.html#a94decde67d97df23a5959d489659b322">gender</a>='user')</td></tr>
<tr class="memitem:a29f037f468ee2716970ae6e7293644e2"><td class="memItemLeft" align="right" valign="top">&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="user_2utils_8php.html#a29f037f468ee2716970ae6e7293644e2">getUserBadge</a> ($uid, $email=false, $default='?')</td></tr>
<tr class="memitem:abfcbff4a35e363f8999bfa976125f491"><td class="memItemLeft" align="right" valign="top">&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="user_2utils_8php.html#abfcbff4a35e363f8999bfa976125f491">getUserRoles</a> ($uid)</td></tr>
</table>
<hr/><h2>Function Documentation</h2>
<a class="anchor" id="a5bbc4a39c360e15b0c00714f18d2082b"></a>
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">assertProfileFilled </td>
          <td>(</td>
          <td class="paramtype">&#160;</td>
          <td class="paramname"><em>$quiet</em> = <code>false</code></td><td>)</td>
          <td></td>
        </tr>
      </table>
</div><div class="memdoc">
<p>Returns whether the user filled his basic profile information, displays a message if not. </p>
<dl class="params"><dt>Parameters:</dt><dd>
  <table class="params">
    <tr><td class="paramname">$quiet</td><td>(optional) Defaults to false. If true, no message is displayed. </td></tr>
  </table>
  </dd>
</dl>

<p>Definition at line <a class="el" href="user_2utils_8php_source.html#l00043">43</a> of file <a class="el" href="user_2utils_8php_source.html">utils.php</a>.</p>

<p>Referenced by <a class="el" href="profile_8php_source.html#l00395">actionEditMotivationLetter()</a>, <a class="el" href="tutoring_8php_source.html#l00023">actionEditTutoringApplication()</a>, <a class="el" href="workshop_8php_source.html#l00385">actionEditWorkshop()</a>, <a class="el" href="utils_8php_source.html#l00047">actionHomepage()</a>, and <a class="el" href="workshop_8php_source.html#l00026">actionListPublicWorkshops()</a>.</p>
<div class="fragment"><div class="line">{</div>
<div class="line">        global $USER, <a class="code" href="common_8php.html#a7dc56dc8b18ad37272b56fa7395bedef">$DB</a>, <a class="code" href="index_8php.html#ae1848ae8dc4014bc7c680e5504a8eef0">$PAGE</a>;</div>
<div class="line">        $user = $DB-&gt;users[$USER[<span class="stringliteral">&#39;uid&#39;</span>]]-&gt;assoc(<span class="stringliteral">&#39;school,graduationyear,interests&#39;</span>);</div>
<div class="line"></div>
<div class="line">        <span class="keywordflow">if</span> (empty($user[<span class="stringliteral">&#39;graduationyear&#39;</span>]) || empty($user[<span class="stringliteral">&#39;school&#39;</span>]) || empty($user[<span class="stringliteral">&#39;interests&#39;</span>]))</div>
<div class="line">        {</div>
<div class="line">                <span class="keywordflow">if</span> (!$quiet)</div>
<div class="line">                        $PAGE-&gt;addMessage(_(<span class="stringliteral">&#39;Fill in &lt;a href=&quot;editProfile&quot;&gt;your profile&lt;/a&gt; first!&#39;</span>), <span class="stringliteral">&#39;userError&#39;</span>);</div>
<div class="line">                <span class="keywordflow">return</span> <span class="keyword">false</span>;</div>
<div class="line">        }</div>
<div class="line">        <span class="keywordflow">return</span> <span class="keyword">true</span>;</div>
<div class="line">}</div>
</div><!-- fragment -->
</div>
</div>
<a class="anchor" id="a94decde67d97df23a5959d489659b322"></a>
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">gender </td>
          <td>(</td>
          <td class="paramtype">&#160;</td>
          <td class="paramname"><em>$m</em> = <code>'y'</code>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">&#160;</td>
          <td class="paramname"><em>$f</em> = <code>'a'</code>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">&#160;</td>
          <td class="paramname"><em>$gender</em> = <code>'user'</code>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>Definition at line <a class="el" href="user_2utils_8php_source.html#l00057">57</a> of file <a class="el" href="user_2utils_8php_source.html">utils.php</a>.</p>

<p>Referenced by <a class="el" href="user_2utils_8php_source.html#l00074">genderize()</a>.</p>
<div class="fragment"><div class="line">{</div>
<div class="line">        global $USER;</div>
<div class="line">        <span class="keywordflow">if</span> ($gender === <span class="stringliteral">&#39;user&#39;</span>)</div>
<div class="line">                $gender = $USER[<span class="stringliteral">&#39;gender&#39;</span>];</div>
<div class="line">        <span class="keywordflow">return</span> (($gender === <span class="charliteral">&#39;f&#39;</span>) ? $f : $m);</div>
<div class="line">}</div>
</div><!-- fragment -->
</div>
</div>
<a class="anchor" id="a7144fa5a413ad5690425b7b720aeedba"></a>
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">genderize </td>
          <td>(</td>
          <td class="paramtype">&#160;</td>
          <td class="paramname"><em>$s</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">&#160;</td>
          <td class="paramname"><em>$gender</em> = <code>'user'</code>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div><div class="memdoc">
<p>Inflect words in a translated string to account for a user's grammatical gender. English doesn't need it, so the string is left unchanged. Currently only Polish is supported - if a string returned by gettext() contains the special character $, a part will be replaced with the appropriate suffix. </p>
<dl class="params"><dt>Parameters:</dt><dd>
  <table class="params">
    <tr><td class="paramname">$s</td><td>string returned by gettext() (_(), n_() or ngettext()). </td></tr>
    <tr><td class="paramname">$gender</td><td>(optional) Defaults to $USER['gender']. Should be 'f','m' or 'p' (plural), other strings are treated as 'm'. </td></tr>
  </table>
  </dd>
</dl>

<p>Definition at line <a class="el" href="user_2utils_8php_source.html#l00074">74</a> of file <a class="el" href="user_2utils_8php_source.html">utils.php</a>.</p>

<p>Referenced by <a class="el" href="admin_8php_source.html#l00036">actionAdminUsers()</a>, <a class="el" href="profile_8php_source.html#l00395">actionEditMotivationLetter()</a>, <a class="el" href="profile_8php_source.html#l00084">actionEditProfile()</a>, <a class="el" href="admin_8php_source.html#l00124">actionEditUserStatus()</a>, <a class="el" href="workshop_8php_source.html#l00026">actionListPublicWorkshops()</a>, <a class="el" href="profile_8php_source.html#l00015">actionShowProfile()</a>, <a class="el" href="tasks_8php_source.html#l00430">actionShowTaskSolutions()</a>, <a class="el" href="workshop_8php_source.html#l00339">actionShowWorkshopTasks()</a>, <a class="el" href="user_8php_source.html#l00146">addUserMenuBox()</a>, <a class="el" href="tasks_8php_source.html#l00248">buildParticipantList()</a>, and <a class="el" href="utils_8php_source.html#l00212">buildTodoElement()</a>.</p>
<div class="fragment"><div class="line">{</div>
<div class="line">        <span class="keywordflow">if</span> ($gender == <span class="charliteral">&#39;p&#39;</span>)</div>
<div class="line">                <span class="keywordflow">return</span> str_replace(<span class="stringliteral">&#39;ł$a&#39;</span>, <span class="stringliteral">&#39;li&#39;</span>, str_replace(<span class="stringliteral">&#39;$y&#39;</span>, <span class="stringliteral">&#39;ych&#39;</span>, $s));</div>
<div class="line">        $s = str_replace(<span class="stringliteral">&#39;$ś&#39;</span>, <a class="code" href="user_2utils_8php.html#a94decde67d97df23a5959d489659b322">gender</a>(<span class="stringliteral">&#39;eś&#39;</span>,<span class="stringliteral">&#39;aś&#39;</span>,$gender), $s);</div>
<div class="line">        $s = str_replace(<span class="stringliteral">&#39;$y&#39;</span>, <a class="code" href="user_2utils_8php.html#a94decde67d97df23a5959d489659b322">gender</a>(<span class="charliteral">&#39;y&#39;</span>,<span class="charliteral">&#39;a&#39;</span>,$gender), $s);</div>
<div class="line">        $s = str_replace(<span class="stringliteral">&#39;$a&#39;</span>, <a class="code" href="user_2utils_8php.html#a94decde67d97df23a5959d489659b322">gender</a>(<span class="stringliteral">&#39;&#39;</span>,<span class="charliteral">&#39;a&#39;</span>,$gender), $s);</div>
<div class="line">        <span class="keywordflow">return</span> $s;</div>
<div class="line">}</div>
</div><!-- fragment -->
</div>
</div>
<a class="anchor" id="a29f037f468ee2716970ae6e7293644e2"></a>
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">getUserBadge </td>
          <td>(</td>
          <td class="paramtype">&#160;</td>
          <td class="paramname"><em>$uid</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">&#160;</td>
          <td class="paramname"><em>$email</em> = <code>false</code>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">&#160;</td>
          <td class="paramname"><em>$default</em> = <code>'?'</code>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div><div class="memdoc">
<p>Returns a user's name with an icon linking to his profile. </p>
<dl class="params"><dt>Parameters:</dt><dd>
  <table class="params">
    <tr><td class="paramname">$uid</td><td>an uid. </td></tr>
    <tr><td class="paramname">$email</td><td>(optional) Defaults to false. If true, his email is also displayed. </td></tr>
    <tr><td class="paramname">$default</td><td>(optional) Defaults to '?'. The name to use for invalid uid (e.g. in old logs). </td></tr>
  </table>
  </dd>
</dl>

<p>Definition at line <a class="el" href="user_2utils_8php_source.html#l00090">90</a> of file <a class="el" href="user_2utils_8php_source.html">utils.php</a>.</p>

<p>Referenced by <a class="el" href="admin_8php_source.html#l00124">actionEditUserStatus()</a>, <a class="el" href="workshop_8php_source.html#l00385">actionEditWorkshop()</a>, <a class="el" href="workshop_8php_source.html#l00542">actionEditWorkshopLecturers()</a>, <a class="el" href="profile_8php_source.html#l00015">actionShowProfile()</a>, <a class="el" href="tasks_8php_source.html#l00430">actionShowTaskSolutions()</a>, <a class="el" href="tutoring_8php_source.html#l00089">actionViewTutoringApplication()</a>, <a class="el" href="tutoring_8php_source.html#l00064">actionViewTutoringApplications()</a>, and <a class="el" href="tasks_8php_source.html#l00248">buildParticipantList()</a>.</p>
<div class="fragment"><div class="line">{</div>
<div class="line">        global $USER, <a class="code" href="common_8php.html#a7dc56dc8b18ad37272b56fa7395bedef">$DB</a>;</div>
<div class="line">        <span class="keywordflow">if</span> (!isset($DB-&gt;users[intval($uid)]))</div>
<div class="line">                <span class="keywordflow">return</span> $default;</div>
<div class="line">        $name = $DB-&gt;users[intval($uid)]-&gt;get(<span class="stringliteral">&#39;name&#39;</span>);</div>
<div class="line">        $icon = <span class="stringliteral">&#39;user-blue.gif&#39;</span>;</div>
<div class="line">        <span class="keywordflow">if</span> ($uid == $USER[<span class="stringliteral">&#39;uid&#39;</span>])</div>
<div class="line">                $icon = <span class="stringliteral">&#39;user-green.gif&#39;</span>;</div>
<div class="line"></div>
<div class="line">        <span class="keywordflow">if</span> (<a class="code" href="user_2utils_8php.html#a1e9c8ed2c5ed2def1a367c9ffd04114b">userCan</a>(<span class="stringliteral">&#39;editProfile&#39;</span>, $uid))</div>
<div class="line">                $icon = <a class="code" href="template_8php.html#a4fbd311bbd72b7beba6f27fe63b0acb1">getIcon</a>($icon, _(<span class="stringliteral">&#39;edit profile&#39;</span>), <span class="stringliteral">&#39;editProfile(&#39;</span>. $uid .<span class="charliteral">&#39;)&#39;</span>);</div>
<div class="line">        <span class="keywordflow">else</span></div>
<div class="line">                $icon = <a class="code" href="template_8php.html#a4fbd311bbd72b7beba6f27fe63b0acb1">getIcon</a>($icon, _(<span class="stringliteral">&#39;profile on wikidot&#39;</span>), <span class="comment">// TODO profile on wikidot exists?</span></div>
<div class="line">                        <span class="stringliteral">&#39;http://warsztatywww.wikidot.com/&#39;</span>. urlencode($name));</div>
<div class="line">        $result = <span class="stringliteral">&quot;$icon $name&quot;</span>;</div>
<div class="line">        <span class="keywordflow">if</span> ($email)  $result .= <span class="stringliteral">&#39; &amp;lt;&#39;</span>. $DB-&gt;users[$uid]-&gt;get(<span class="stringliteral">&#39;email&#39;</span>) .<span class="stringliteral">&#39;&amp;gt;&#39;</span>;</div>
<div class="line">        <span class="keywordflow">return</span> $result;</div>
<div class="line">}</div>
</div><!-- fragment -->
</div>
</div>
<a class="anchor" id="abfcbff4a35e363f8999bfa976125f491"></a>
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">getUserRoles </td>
          <td>(</td>
          <td class="paramtype">&#160;</td>
          <td class="paramname"><em>$uid</em></td><td>)</td>
          <td></td>
        </tr>
      </table>
</div><div class="memdoc">
<p>Returns an array of roles given user has. Possible roles are 'admin','tutor' (from table_user_roles), 'lecturer', 'candidate', 'qualified' (from table_edition_users), 'registered', 'public', 'owner' (these are not set here, but in <a class="el" href="user_2utils_8php.html#a1e9c8ed2c5ed2def1a367c9ffd04114b">userCan()</a> or <a class="el" href="user_8php.html#a5fa3ca13e5c8bc79a08d3fc4972f7a95">getUser()</a>). </p>
<dl class="params"><dt>Parameters:</dt><dd>
  <table class="params">
    <tr><td class="paramname">$uid</td><td>an uid. </td></tr>
  </table>
  </dd>
</dl>

<p>Definition at line <a class="el" href="user_2utils_8php_source.html#l00117">117</a> of file <a class="el" href="user_2utils_8php_source.html">utils.php</a>.</p>

<p>Referenced by <a class="el" href="admin_8php_source.html#l00036">actionAdminUsers()</a>, <a class="el" href="admin_8php_source.html#l00124">actionEditUserStatus()</a>, and <a class="el" href="user_8php_source.html#l00044">getUser()</a>.</p>
<div class="fragment"><div class="line">{</div>
<div class="line">        global <a class="code" href="common_8php.html#a7dc56dc8b18ad37272b56fa7395bedef">$DB</a>, $USER;</div>
<div class="line">        $DB-&gt;query(<span class="stringliteral">&#39;SELECT role FROM table_user_roles WHERE uid=$1&#39;</span>, $uid);</div>
<div class="line">        $roles = $DB-&gt;fetch_column();</div>
<div class="line">        $r = $DB-&gt;query(<span class="stringliteral">&#39;SELECT lecturer, qualified FROM table_edition_users WHERE edition=$1 AND uid=$2&#39;</span>,</div>
<div class="line">                <a class="code" href="utils_8php.html#a86acce3c002ca1af709fd1b04f2f82fa">getOption</a>(<span class="stringliteral">&#39;currentEdition&#39;</span>), $uid);</div>
<div class="line">        <span class="keywordflow">if</span> ($r-&gt;count())</div>
<div class="line">        {</div>
<div class="line">                $status = $DB-&gt;fetch_assoc();</div>
<div class="line">                $roles[]= ($status[<span class="stringliteral">&#39;lecturer&#39;</span>]) ? <span class="stringliteral">&#39;lecturer&#39;</span> : <span class="stringliteral">&#39;candidate&#39;</span>;</div>
<div class="line">                <span class="keywordflow">if</span> ($status[<span class="stringliteral">&#39;qualified&#39;</span>])</div>
<div class="line">                        $roles[]= <span class="stringliteral">&#39;qualified&#39;</span>;</div>
<div class="line">        }</div>
<div class="line">        <span class="keywordflow">return</span> $roles;</div>
<div class="line">}</div>
</div><!-- fragment -->
</div>
</div>
<a class="anchor" id="a1e9c8ed2c5ed2def1a367c9ffd04114b"></a>
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">userCan </td>
          <td>(</td>
          <td class="paramtype">&#160;</td>
          <td class="paramname"><em>$action</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">&#160;</td>
          <td class="paramname"><em>$owners</em> = <code>false</code>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div><div class="memdoc">
<p>Return whether current user has rights to do given action. table_role_permissions contains for each action several entries - each entry is a concatenation (space-separated) of required roles, if any one of these entries is fully fulfilled, permission is granted. </p>
<dl class="params"><dt>Parameters:</dt><dd>
  <table class="params">
    <tr><td class="paramname">$action</td><td>the action to be checked. </td></tr>
    <tr><td class="paramname">$owners</td><td>a single uid or an array of uids - if the current user belongs here, the role 'owner' is added. </td></tr>
  </table>
  </dd>
</dl>

<p>Definition at line <a class="el" href="user_2utils_8php_source.html#l00025">25</a> of file <a class="el" href="user_2utils_8php_source.html">utils.php</a>.</p>

<p>Referenced by <a class="el" href="admin_8php_source.html#l00036">actionAdminUsers()</a>, <a class="el" href="utils_8php_source.html#l00237">actionApplyAsLecturer()</a>, <a class="el" href="utils_8php_source.html#l00243">actionApplyAsParticipant()</a>, <a class="el" href="tutoring_8php_source.html#l00119">actionConsiderTutoringApplication()</a>, <a class="el" href="tasks_8php_source.html#l00138">actionDeleteTask()</a>, <a class="el" href="profile_8php_source.html#l00280">actionEditAdditionalInfo()</a>, <a class="el" href="profile_8php_source.html#l00395">actionEditMotivationLetter()</a>, <a class="el" href="utils_8php_source.html#l00336">actionEditOptions()</a>, <a class="el" href="profile_8php_source.html#l00084">actionEditProfile()</a>, <a class="el" href="tasks_8php_source.html#l00086">actionEditTask()</a>, <a class="el" href="tutoring_8php_source.html#l00023">actionEditTutoringApplication()</a>, <a class="el" href="tutoring_8php_source.html#l00049">actionEditTutoringApplicationForm()</a>, <a class="el" href="admin_8php_source.html#l00124">actionEditUserStatus()</a>, <a class="el" href="workshop_8php_source.html#l00385">actionEditWorkshop()</a>, <a class="el" href="workshop_8php_source.html#l00542">actionEditWorkshopLecturers()</a>, <a class="el" href="workshop_8php_source.html#l00072">actionListAllWorkshops()</a>, <a class="el" href="summary_8php_source.html#l00132">actionListArrivalData()</a>, <a class="el" href="summary_8php_source.html#l00191">actionListDailyCounts()</a>, <a class="el" href="workshop_8php_source.html#l00057">actionListOwnWorkshops()</a>, <a class="el" href="summary_8php_source.html#l00096">actionListPersonalData()</a>, <a class="el" href="workshop_8php_source.html#l00026">actionListPublicWorkshops()</a>, <a class="el" href="workshop_8php_source.html#l00583">actionRemoveWorkshopLecturer()</a>, <a class="el" href="error_8php_source.html#l00306">actionShowErrorLog()</a>, <a class="el" href="log_8php_source.html#l00034">actionShowLog()</a>, <a class="el" href="profile_8php_source.html#l00015">actionShowProfile()</a>, <a class="el" href="workshop_8php_source.html#l00339">actionShowWorkshopTasks()</a>, <a class="el" href="workshop_8php_source.html#l00674">actionSignUpForWorkshop()</a>, <a class="el" href="tutoring_8php_source.html#l00089">actionViewTutoringApplication()</a>, <a class="el" href="tutoring_8php_source.html#l00064">actionViewTutoringApplications()</a>, <a class="el" href="page_8php_source.html#l00062">Page\addMenuBox()</a>, <a class="el" href="tutoring_8php_source.html#l00011">addTutoringMenuBox()</a>, <a class="el" href="user_8php_source.html#l00146">addUserMenuBox()</a>, <a class="el" href="tasks_8php_source.html#l00248">buildParticipantList()</a>, <a class="el" href="tasks_8php_source.html#l00009">buildTaskList()</a>, <a class="el" href="utils_8php_source.html#l00212">buildTodoElement()</a>, <a class="el" href="user_2utils_8php_source.html#l00090">getUserBadge()</a>, and <a class="el" href="user_8php_source.html#l00027">initUser()</a>.</p>
<div class="fragment"><div class="line">{</div>
<div class="line">        global $USER, <a class="code" href="common_8php.html#a7dc56dc8b18ad37272b56fa7395bedef">$DB</a>;</div>
<div class="line">        $roles = $USER[<span class="stringliteral">&#39;roles&#39;</span>];</div>
<div class="line">        <span class="keywordflow">if</span> ($owners === $USER[<span class="stringliteral">&#39;uid&#39;</span>] || (is_array($owners) &amp;&amp; in_array($USER[<span class="stringliteral">&#39;uid&#39;</span>], $owners)))</div>
<div class="line">                <span class="keywordflow">if</span> (in_array(<span class="stringliteral">&#39;registered&#39;</span>, $USER[<span class="stringliteral">&#39;roles&#39;</span>]))</div>
<div class="line">                        $roles[]= <span class="stringliteral">&#39;owner&#39;</span>;</div>
<div class="line">        $required = $DB-&gt;query(<span class="stringliteral">&#39;SELECT role FROM table_role_permissions WHERE action=$1&#39;</span>, $action);</div>
<div class="line">        <span class="keywordflow">foreach</span> ($required as $requirements)</div>
<div class="line">                <span class="keywordflow">if</span> (!count(array_diff(explode(<span class="charliteral">&#39; &#39;</span>, $requirements[<span class="stringliteral">&#39;role&#39;</span>]), $roles)))</div>
<div class="line">                        <span class="keywordflow">return</span> <span class="keyword">true</span>;</div>
<div class="line">        <span class="keywordflow">return</span> <span class="keyword">false</span>;</div>
<div class="line">}</div>
</div><!-- fragment -->
</div>
</div>
<a class="anchor" id="ae6297fbd3e8fa7cc5feb6411a80deee9"></a>
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">userIs </td>
          <td>(</td>
          <td class="paramtype">&#160;</td>
          <td class="paramname"><em>$role</em></td><td>)</td>
          <td></td>
        </tr>
      </table>
</div><div class="memdoc">
<p>Returns whether current user has given role. </p>
<dl class="params"><dt>Parameters:</dt><dd>
  <table class="params">
    <tr><td class="paramname">$role</td><td>a role name, see <a class="el" href="user_2utils_8php.html#abfcbff4a35e363f8999bfa976125f491">getUserRoles()</a>. </td></tr>
  </table>
  </dd>
</dl>

<p>Definition at line <a class="el" href="user_2utils_8php_source.html#l00010">10</a> of file <a class="el" href="user_2utils_8php_source.html">utils.php</a>.</p>

<p>Referenced by <a class="el" href="user_8php_source.html#l00262">actionChangePassword()</a>, <a class="el" href="utils_8php_source.html#l00415">actionDatabaseRaw()</a>, <a class="el" href="profile_8php_source.html#l00280">actionEditAdditionalInfo()</a>, <a class="el" href="email_8php_source.html#l00121">actionFetchGmailOAuthAccessToken()</a>, <a class="el" href="utils_8php_source.html#l00047">actionHomepage()</a>, <a class="el" href="utils_8php_source.html#l00270">actionReportBug()</a>, <a class="el" href="admin_8php_source.html#l00009">addAdminMenuBox()</a>, and <a class="el" href="utils_8php_source.html#l00212">buildTodoElement()</a>.</p>
<div class="fragment"><div class="line">{</div>
<div class="line">        global $USER;</div>
<div class="line">        <span class="keywordflow">return</span> in_array($role, $USER[<span class="stringliteral">&#39;roles&#39;</span>]);</div>
<div class="line">}</div>
</div><!-- fragment -->
</div>
</div>
</div><!-- contents -->
<!-- start footer part -->
<hr class="footer"/><address class="footer"><small>
Generated on Sun Sep 8 2013 17:44:57 for wwwApp by &#160;<a href="http://www.doxygen.org/index.html">
<img class="footer" src="doxygen.png" alt="doxygen"/>
</a> 1.8.1.1
</small></address>
</body>
</html>
